<!--
 * @Author: uphldjx 1373577124@qq.com
 * @Date: 2023-08-02 13:50:49
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2023-08-08 17:26:44
 * @FilePath: \NingxiangElderlyCare\src\views\system\role\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
	<BaseContainer>
		<div class="w-100">
			<aplid-base-crud ref="crud" v-bind="baseConfig" :operateFormate="operateFormate">
				<template v-slot:addDialog="{ row, show }">
					<tabForm @refresh="handleRefresh" :api="baseConfig.api" :key="show" :nowRowData="row"></tabForm>
				</template>
				<template v-slot:authSetDialog="{ row, show }">
					<authSet @refresh="handleRefresh" :key="show" :nowRowData="row"></authSet>
				</template>
			</aplid-base-crud>
		</div>
	</BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import tabForm from './components/tabForm/index.vue'
import authSet from './components/authSet/index.vue'
const router = useRouter()
const crud = ref(null)

const handleRefresh = () => {
	nextTick(() => {
		crud.value.refreshChange()
	})
}
const operateFormate = (rowData,type) => {
	return new Promise<void>((resolve, reject) => {
		if(type === 'workSpace'){
			router.push({
				path: '/workSpace',
				query: {
					id: rowData.roleId,
					name: rowData.roleName
				}
			})
		}else{
			resolve(rowData)
		}
	})
}
</script>

<style scoped></style>
